<template>
  <div class="depengingDialog_box">
    <el-dialog title="伯图互联网医院处方笺" :visible.sync="dialogShow" width="720px" @close="cancelInfo" center>
      <div class="dialogTitle">普通处方</div>
      <div class="modelInfo">
        <vue-scroll ref="vs" :ops="$store.state.ops">
          <div class="modelInfo_box">
            <div class="prescription_content">
              <div class="userName_label">姓名</div>
              <div class="userName_content">{{userInfo.name |patientName}}</div>
              <div class="userName_label">性别</div>
              <div class="userName_content">{{userInfo.sex |patientSex}}</div>
              <div class="userName_label">年龄</div>
              <div class="userName_content">{{userInfo.age |patientAge}}</div>
              <div class="diagnosis">
                <div class="userName_label">初步诊断</div>
                <div class="userName_content">{{userInfo.firstDiagnose}}</div>
              </div>
              <div class="diagnosis">
                <div class="userName_label">开方日期</div>
                <div class="userName_content">{{userInfo.createTime | timeFilter }}</div>
              </div>
            </div>
            <div class="drugsList">
              <img src="/static/img/Rx@2x.png" alt="" class="drugsImg">
              <ul>
                <li class="drugsItem" v-for="(item,index) in drugList" :key="index">
                  <div class="itemTitle">{{index + 1}}. {{item.drugName}}&nbsp;&nbsp;{{item.drugSize}}</div>
                  <div class="itemContent">
                    <div class="itemTitles">数量：{{item.drugCount}}{{item.drugCountUnit}}</div>
                    <div class="itemTitles">用法：{{item.drugMethods}}&nbsp;&nbsp;每次{{item.drugDose}}{{item.drugDoseUnit}}&nbsp;&nbsp;{{item.drugFrequency}}&nbsp;&nbsp;用药{{item.drugTime}}</div>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </vue-scroll>
      </div>
      <footer class="footer">
        <div class="addItem cursor" @click="change" v-if="reviewTrue">重新编辑</div>
        <div class="addItem submit cursor" @click="submit">提交</div>
      </footer>
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {},
  props: ["showTrue", "reviewShow", "prescriptionData"],
  data() {
    return {
      dialogShow: false,
      notClick: false,
      drugList: [],
      userInfo: {},
      reviewTrue: false
    };
  },
  filters: {
    timeFilter(val) {
      if (val) {
        var standardTime = new Date(val * 1);
        var y, m, d, h, f;
        y = standardTime.getFullYear();
        m = standardTime.getMonth() + 1;
        m = m > 9 ? m : "0" + m;
        d = standardTime.getDate();
        d = d > 9 ? d : "0" + d;
        h = standardTime.getHours();
        h = h > 9 ? h : "0" + h;
        f = standardTime.getMinutes();
        f = f > 9 ? f : "0" + f;
        return `${y}.${m}.${d} ${h}:${f}`;
      } else {
        return "暂无";
      }
    },
    patientName: function(val) {
      return val ? val : "未知";
    },
    patientSex: function(val) {
      var data = "";
      if (val == 0) {
        data = "女";
      } else if (val == 1) {
        data = "男";
      } else {
        data = "未知";
      }
      return data;
    },
    patientAge: function(val) {
      return val ? val + "岁" : "未知";
    }
  },
  created() {
    this.reviewTrue = this.reviewShow;
  },
  mounted() {},
  activited() {},
  update() {},
  beforeRouteUpdate() {},
  methods: {
    submit() {
      this.$emit("submit", "123");
    },
    change() {
      this.$emit("change", "123");
    },
    cancelInfo() {
      this.$emit("close", false);
    }
  },

  computed: {},
  watch: {
    showTrue(val) {
      this.dialogShow = val;
    },
    reviewShow(val) {
      this.reviewTrue = val;
    },
    prescriptionData(val) {
      var data = val;
      this.userInfo = data.userInfo;
      this.drugList = data.drugList;
    }
  }
};
</script>

<style scoped>
.dialogTitle {
  font-size: 16px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: bold;
  color: rgba(42, 41, 40, 1);
  margin-left: 40px;
  height: 60px;
  width: 80%;
  display: flex;
  align-items: center;
  overflow: hidden;
  font-weight: 400;
}

.drugsList {
}
.drugsLi {
  width: 640px;
  height: 217px;
  border-radius: 3px;
  border: 1px solid rgba(228, 228, 228, 1);
  margin-top: 20px;
  box-sizing: border-box;
  padding: 0px 20px;
  position: relative;
  overflow: hidden;
}
.deleteImg {
  position: absolute;
  width: 16px;
  height: 16px;
  top: 16px;
  right: 20px;
  cursor: pointer;
}
.liItem {
  font-size: 14px;
  margin-bottom: 14px;
}
.footer {
  width: 100%;
  height: 100px;
  background-color: #f1f1f1;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.addItem {
  width: 150px;
  height: 40px;
  background: rgba(255, 199, 73, 1);
  border-radius: 20px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  line-height: 40px;
  text-align: center;
  margin: 0 15px;
}
.addItem img {
  width: 12px;
  height: 12px;
  vertical-align: inherit;
}
.submit {
  background-color: #ff6532;
}
.notClick {
  background-color: #ccc;
}

.modelInfo {
  height: 485px;
  overflow: hidden;
}
.modelInfo_box {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 40px;
  padding-bottom: 25px;
}
.prescription_content {
  box-sizing: border-box;
  border-radius: 3px;
  border: 1px solid rgba(228, 228, 228, 1);
  width: 640px;
  padding: 24px 20px;
}
.userName_label {
  display: inline-block;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(122, 118, 118, 1);
  margin-right: 12px;
}
.userName_content {
  display: inline-block;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(55, 55, 55, 1);
  margin-right: 100px;
}
.diagnosis {
  margin-top: 12px;
}
.drugsList {
  margin-top: 20px;
  width: 640px;
  border-radius: 3px;
  border: 1px solid rgba(228, 228, 228, 1);
  box-sizing: border-box;
  padding: 20px;
}
.drugsImg {
  display: block;
  width: 24px;
  height: 24px;
}
.drugsItem {
  margin-top: 14px;
}
.itemTitle {
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: bold;
  color: rgba(55, 55, 55, 1);
}
.itemTitles {
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  color: rgba(122, 118, 118, 1);
  margin-right: 30px;
}
.itemContent {
  box-sizing: border-box;
  padding-left: 15px;
  margin-top: 8px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(122, 118, 118, 1);
  display: flex;
  align-items: center;
}
/* .itemContent > span {
  display: inline-block;
  margin-right: 30px;
} */
.cancelBox {
  float: right;
  width: 120px;
  height: 34px;
  background: rgba(42, 41, 40, 1);
  border-radius: 20px;
  position: absolute;
  top: 13px;
  right: 40px;
  color: #fff;
  cursor: pointer;
  line-height: 34px;
  text-align: center;
}
.alertBox {
  position: fixed;
  width: 100vw;
  height: 100vh;
  z-index: 9;
}
</style>
<style>
.el-dialog {
  width: 45%;
  border-radius: 8px;
}
.el-dialog__body {
  padding: 0 !important;
  border-radius: 8px;
  overflow: hidden;
}
.depengingDialog_box .el-input {
  width: 85%;
  margin-left: 15px;
}
</style>